import dt from '@dt/dt'
import toolMgr from '@/biz/base/tool.js'

function options(_this, detail = false) {
  let data = [
    {
      title: '房源套数',
      key: 'roomCount',
      text: {},
      data: {
        from: (info) => {
          return info.roomCount + '套'
        }
      }
    },
    {
      title: '总签约金额',
      key: 'sumAmount',
      text: {
        type: 'number',
        unit: '元'
      }
    },
    {
      title: '电子版附件',
      key: 'digitalAttaches',
      col: 24,
      tag: {
        type: 'text',
        closable: false,
        options: _this.info.digitalAttaches?.map((item) => {
          return {
            value: item.fileName,
            key: item.attachAddress
          }
        }),
        color: 'blue',
        click: (tag) => {
          toolMgr.downloadFile(tag.key, tag.value)
        }
      }
    },
    {
      title: '备注',
      key: 'remark',
      text: {},
      col: 24
    }
  ]
  if (detail && _this.info.status == 'BACK') {
    data.push({
      title: '退回原因',
      key: 'backReason',
      text: {},
      col: 8
    })
  }
  return data
}

export default {
  options
}
